﻿#region License
/* ---------------------------------------------------------------- *
 *
 * This file is part of the Xcoordination Application Space
 * ("XcoAppSpace") http://www.xcoordination.com
 *
 * Copyright (C) 2009 Xcoordination http://www.xcoordination.com
 *
 * XcoAppSpace is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General
 * Public License as published by the Free Software Foundation.
 *
 * XcoAppSpace is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 * or write to the Free Software Foundation, Inc., 51 Franklin
 * Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * ---------------------------------------------------------------- */
#endregion

using System;
using Microsoft.Ccr.Core;
using XcoAppSpaces.Contracts.Messaging;

namespace XcoAppSpaces.Core.CcrWiring.CcrRemote
{
	/// <summary>
	/// Special Ccr task that can send data that has been posted to a port to an anonymous remote port instance
	/// (identified remotely by the given port guid).
	/// </summary>
	class AnonymousRemotableTask : RemotableTask
	{
		public AnonymousRemotableTask(Handler<MessageToSend> messageProcessor, string sourcePortAddress, string commServiceName, Guid portGuid, IPort assignedPort, MessageTransferMode mode)
            : base(messageProcessor, sourcePortAddress, commServiceName, portGuid, assignedPort, mode)
		{
		}

		public override ITask PartialClone()
		{
			return new AnonymousRemotableTask(messageProcessor, RemoteAddress, CommServiceName, PortGuid, assignedPort, Mode);
		}

		protected override RemoteMessage CreateMessage(object value)
		{
			return new RemotePortMessage(PortGuid, value);
		}

		public override RemotableTask PartialClone(IPort newAssignedPort, MessageTransferMode newMode)
		{
			return new AnonymousRemotableTask(messageProcessor, RemoteAddress, CommServiceName, PortGuid, newAssignedPort, newMode);
		}
	}
}
